# Django settings for trespams blog project.
# -*- coding: UTF-8 -*-

# You have to customize your properties files. Just make a copy from
# properties.py.template and change the parameters to adapt them to your needs.
import properties
import os

import logging
import logging.config
logging.config.fileConfig(getattr(properties, 'logconf', 'loggin.conf'))

logger = logging.getLogger(getattr(properties,'logger', 'trespams'))

DEFAULT_ENCODINT="utf-8"
DEBUG = getattr(properties, 'debug', True)
TEMPLATE_DEBUG = getattr(properties, 'debug', True)
SITE_ROOT = getattr(properties, 'site_root',  os.path.dirname(__file__))
USE_ETAGS = getattr(properties, 'use_etags', True)

MANAGERS = getattr(properties, 'admins', ['antoni.aloy@trespams.com',])

DATABASE_ENGINE = properties.database_engine               # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = properties.database_name                   # Or path to database file if using sqlite3.
DATABASE_USER = properties.database_user                   # Not used with sqlite3.
DATABASE_PASSWORD = properties.database_password           # Not used with sqlite3.
DATABASE_HOST = properties.database_host                   # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = properties.database_port                   # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be avilable on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = properties.time_zone

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = getattr(properties, 'language_code', 'es-ca')

SITE_ID = getattr(properties, 'site_id', 1)

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = getattr(properties, 'media_root', os.path.join(SITE_ROOT,'media'))

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = getattr(properties, 'media_url', 'http://localhost:8000/media/')

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = getattr(properties, 'admin_media_prefix','/adm_media/')

# Make this unique, and don't share it with anybody.
SECRET_KEY = properties.secret_key

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',

#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.locale.LocaleMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    'django.middleware.gzip.GZipMiddleware',
    'django.middleware.doc.XViewMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.http.ConditionalGetMiddleware',
)

DEBUG_TOOLBAR_ACTIVE = getattr(properties, 'debug_toolbar_active', False)

if DEBUG and DEBUG_TOOLBAR_ACTIVE:
    MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)

ROOT_URLCONF = getattr(properties, 'urls', 'urls')

TEMPLATE_DIRS = getattr(properties, 'template_dirs', ( (os.path.join(SITE_ROOT, 'templates')),))

INSTALLED_APPS = (
    'admin_tools',
    'admin_tools.theming',
    'admin_tools.menu',
    'admin_tools.dashboard',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.humanize',
    'django.contrib.markup',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.admin',
    'django.contrib.flatpages',
    'blogmaker.blog',
    'blogmaker.comments',
    'blogmaker.util',
    'links',
    #'photologue',
    'robots', # see http://code.google.com/p/django-robots/
    'djapian', # see http://code.google.com/p/djapian/
    #'feedjack',
    #'mailer',
    'compress',
    #'debug_toolbar',
    'django_extensions',
    'memcache_status',
)
# set cache backend
CACHE_BACKEND=getattr(properties, 'cache_backend', 'dummy:///')
CACHE_MIDDLEWARE_KEY_PREFIX = getattr(properties, 'cache_prefix', 'trespams')
CACHE_MIDDLEWARE_SECONDS = getattr(properties, 'cache_seconds', 3600)
CACHE_MIDDLEWARE_ANONYMOUS_ONLY=getattr(properties, 'cache_middleware_anonymous_only', True)
# set session backed
#SESSION_BACKEND=session_backend

if DEBUG:
    SESSION_EXPIRE_AT_BROWSER_CLOSE=True

#Sesion engine if not default
#SESSION_ENGINE=session_engine

ugettext = lambda s:s
LANGUAGES = (
    ('en', ugettext('English')),
    ('es', ugettext('Spanish')),
    ('ca', ugettext('Catalan')),
)

TEMPLATE_CONTEXT_PROCESSORS=("django.core.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.request")

DEFAULT_BLOG_USER=1
COPYRIGHT="apsl.net"
BLOG_ROOT=getattr(properties, 'blog_root', "http://localhost:8000/")
BLOG_MEDIA_PREFIX=getattr(properties, 'blog_media_prefix',"")
BLOG_NAME=properties.blog_name
BLOG_SUBTITLE=properties.blog_subtitle
BLOG_CLOSE_COMMENTS_INTERVAL=getattr(properties, 'blog_close_comments_interval', 30)
URCHIN_CODE=properties.urchin_code
WEBMASTER_META=properties.webmaster_meta
WP_IMPORT=getattr(properties, 'importing', True)
TWITTER_USER =  getattr(properties,'twitter_user','aaloy')
TWITTER_PASSWORD=getattr(properties,'twitter_password','password')
SEND_TWITT_ON_POST = getattr(properties,'send_twitt_on_post', True)

# Configuracion para el envio de correo
EMAIL_HOST = getattr(properties, 'email_host', 'localhost')

# Djapian (indexer) database path
DJAPIAN_DATABASE_PATH = getattr(properties, 'djapian_database_path', '/tmp/trespams')

INTERNAL_IPS=('127.0.0.1',)

DEBUG_TOOLBAR_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.cache.CacheDebugPanel',
    'debug_toolbar.panels.logger.LoggingPanel',
    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',

)

DELICIOUS_USER = getattr(properties, 'delicious_user', 'antoni.aloy')


COMPRESS_CSS = {
    'trespams_css': {
        'source_filenames': (
            'blueprint/screen.css',
            'blueprint/plugins/fancy-type/screen.css',
            'css/trespams.css',
         ),
        'output_filename': 'css/trespams_compressed_r?.css',
        'extra_context' : {'media': 'screen, projection'}
    },
    # other CSS groups goes here
}

COMPRESS_JS = {
    'trespams_js': {
        'source_filenames': ('js/jquery.js', 'js/jquery.highlight-3.yui.js', 'js/jquery.labelify.js',),
        'output_filename': 'js/all_compressed_r?.js',
    }
}

COMPRESS = True
COMPRESS_VERSION = True
USE_PING_URL = getattr(properties, 'use_ping_url', False)
TRACKBACKS_ON_SAVE=getattr(properties,'trackbacks_on_save', False)
